package cn.tedu.boot01.controller;

import cn.tedu.boot01.entity.Emp;
import cn.tedu.boot01.entity.Emp2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

//@Controller
@RestController
public class ParamController {

    @RequestMapping("/p1")
    //@ResponseBody
    public String p1(HttpServletRequest request){
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        return "测试成功p1![name="+name+", age="+age+"]";
    }

    @RequestMapping("/p2")
    //@ResponseBody
    public String p2(String name,int age,String name2){
        return "测试成功p2![name="+name+", age="+age+", name2="+name2+"]";
    }

    @RequestMapping("/p3")
    //@ResponseBody
    public String p3(Emp emp, Emp2 emp2){
        System.out.println("emp = " + emp);
        System.out.println("emp2 = " + emp2);
        return emp.toString()+emp2.toString();
    }
}
